

if modifier_boss == nil then modifier_boss = class({}) end

function modifier_boss:GetBehavior()
    return DOTA_ABILITY_BEHAVIOR_PASSIVE
end

function modifier_boss:IsPurgable()
    return false
end

function modifier_boss:IsHidden()
    return false
end

function modifier_boss:DeclareFunctions()
    return {MODIFIER_PROPERTY_PREATTACK_BONUS_DAMAGE}
end

function modifier_boss:OnCreated(keys)
    self.playerId=keys.playerId
    self.bonusDamage=self:GetParent():GetLevel()*1
    self:StartIntervalThink(2)
end

function modifier_boss:Reset()

end

function modifier_boss:GetModifierPreAttack_BonusDamage()
    return self.bonusDamage
end

function modifier_boss:OnIntervalThink()
    if IsServer() then
        local unit=self:GetParent()
        local heroes= FindUnitsInRadius(DOTA_TEAM_NEUTRALS,unit:GetAbsOrigin(),nil, 800,DOTA_UNIT_TARGET_TEAM_ENEMY, DOTA_UNIT_TARGET_HERO, DOTA_UNIT_TARGET_FLAG_NONE, FIND_ANY_ORDER, false )
        for _,value in pairs(heroes)do
            if value:GetPlayerID()~=self.playerId then
                if value:FindModifierByName(AbilitiesNames.modifier_water_debuff)==nil then
                    value:AddNewModifier(value,nil,AbilitiesNames.modifier_water_debuff,{colorX=0,colorY=0.1,colorZ=0.2})
                end
            end
        end
        unit:SetBaseAttackTime(unit:GetBaseAttackTime()*0.99)
    end
    if self.bonusDamage<10000 then
        self.bonusDamage=self.bonusDamage*1.1
    end
end

function modifier_boss:OnDestroy()
    if IsServer() and self:GetParent():IsAlive()==false then
        BossSpawner.boss=nil
        local hero=Hero.heroList[self.playerId]
        hero:Heal(hero:GetMaxHealth(),hero)
        hero:GiveMana(hero:GetMaxMana())
        local seconds=10
        MsgUtil:Top(self.playerId,{text="#InfoTip_Boss_Area_Close",replacement={seconds=seconds}, style={color=ColorHex.Warn}})
        EmitSoundOnClient(SoundsNames.warning,PlayerResource:GetPlayer(self.playerId))
        Timers:CreateTimer(seconds,function ()
            local tpAbility=  hero:FindAbilityByName(AbilitiesNames.ability_tp)
            local index,pos =Hero:GetRandomSpawnPos(hero)
            tpAbility.nextPos=pos
            tpAbility:CastAbility()
            hero.mapPosIndex=index
            Timers:CreateTimer(5,function ()
                Tower:ShowBossTower()
            end)
        end)
    end
end


